package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class Circle extends Sprite
	{
		private var _Timer:Timer;  //定义时间事件
		public var oCircle:Sprite;  //圆对象
		public var CircleArray:Array=[]  //装载数据
		public 	var depth:int=-1;
		private var CircleColor:uint=0x00ff00;
		public function Circle()
		{
			init()
		this.addEventListener(Event.ENTER_FRAME,onRun)  //添加侦频事件
				
		}
		private function init():void            //开启 事件
		{
			_Timer=new Timer(500)
			_Timer.addEventListener(TimerEvent.TIMER,onTimer)
			_Timer.start()
		}		
		
		//产生添炸弹
		public function onTimer(e:TimerEvent):void
		{
			oCircle=new Sprite()
			oCircle.graphics.beginFill(CircleColor)
			oCircle.graphics.drawCircle(0,0,10)
			oCircle.graphics.endFill()
			oCircle.x=Math.floor(Math.random()*490+5)
			oCircle.y-=20
			depth++
			addChildAt(oCircle,depth)
			CircleArray.push(oCircle)
		}
		public function set setColor(Color:uint):void
		{
			CircleColor = Color
		}
		public function get getColor():uint
		{
		  return CircleColor
		}

	
		//Engter.FRAME  给当前圆y轴
		private function onRun(e:Event):void
		{
			for(var i:int=0;i<CircleArray.length;i++)
			{
				CircleArray[i].y+=5
				if(CircleArray[i].y > stage.stageHeight+CircleArray[i].height/2)
				{
					CircleArray.splice(i,1)  //删除数组当前索引
					removeChildAt(i)       //删除当前深度
					depth--                    //--当前深度索引变量
				}
			}
		}
		

		
		
	}
}